
package com.sfdlJPush.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;

public class VerifyData
{
    /**
     * 验证UC中心的邮箱格式
     * 
     * @param email
     * @return
     */
    public static boolean verifyEmail(String email)
    {
        Pattern pattern = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
        return pattern.matcher(email).matches();
    }

    /**
     * 获取sign签名
     * @param list
     * @param map
     * @return
     */
    public static String getMD5Sign(Map<String, Object> map)
    {
        List<String> lists = new ArrayList<String>();
        for (Entry<String, Object> entry : map.entrySet())
        {
            lists.add(entry.getKey());
        }
        StringBuilder sign = new StringBuilder();
        Collections.sort(lists);
        for (int i = 0; i < lists.size(); i++)
        {
            sign.append(lists.get(i)).append(map.get(lists.get(i)));
        }
        // sign.deleteCharAt(sign.length()-1);
        System.out.println("sign--->" + sign.toString());
        String md5Sign = B5MStringHelper.getMD5Str(sign.toString());
        System.out.println("signMD5--->" + md5Sign);
        return md5Sign;
    }

    public static String getStatus(String status)
    {
        String statusStr = status;
        if ("0".equals(status))
        {
            statusStr = "查询中";
        }
        else if ("1".equals(status))
        {
            statusStr = "处理中";
        }
        else if ("2".equals(status))
        {
            statusStr = "完成";
        }
        return statusStr;
    }
}
